package com.wordpress.music2dot0.server;

import java.net.URL;
import java.util.TimerTask;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlID;

/**
 * Represents a song, including all meta-data
 * 
 * @author raf
 */
public class Song extends TimerTask {
	/**
	 * Group in which the song is currently playing. Null if the song is not
	 * currently playing.
	 */
	private GroupServer group;

	@XmlElement
	@XmlID
	String id;

	@XmlElement
	String name;

	@XmlElement
	URL url;

	@XmlElement
	URL stream;

	@XmlElement
	int duration;

	@XmlElement
	String album_name;

	@XmlElement
	String album_image;

	@XmlElement
	String artist_name;

	@XmlElement
	String tag_idstr;

	@Override
	public void run() {
		this.group.playNext();
		this.group = null;
	}

	/**
	 * Sets the group in which the song is currently playing
	 * 
	 * @param group
	 *            the group in which the song is currently playing
	 */
	public void setGroup(GroupServer group) {
		this.group = group;
	}
}
